#include<iostream>
using namespace std;
int n,h=0,k[12][12]={0};
void ss(int x1,int y1)
{
	int p;
	if(x1==n&&y1==n)
	{
		h++;
	}
	else
	{
		for(p=0;p<4;p++)
		{
			k[x1][y1]=1;
			if(x1!=n&&k[x1+1][y1]==0)
			{
				ss(x1+1,y1);
			}
			else if(y1!=n&&k[x1][y1+1]==0)
			{
				ss(x1,y1+1);
			}
			else if(y1!=1&&k[x1][y1-1]==0)
			{
				ss(x1,y1-1);
			}
			else if(x1!=1&&k[x1-1][y1]==0)
			{
				ss(x1-1,y1);
			}
		}
	}
}
int main()
{
	int x,y;
	cin>>n;
	for(x=1;x<=n;x++)
	{
		for(y=1;y<=n;y++)
		{
			cin>>k[x][y];
		}
	}
	ss(1,1);
	if(h)
	cout<<"YES";
	else
	cout<<"NO";
}
